<template>
  <div class="page-settings">
    <el-form label-width="100px" size="small">
      <el-form-item label="模板名称">
        <el-input v-model="localSettings.name"></el-input>
      </el-form-item>
      <el-form-item label="模板宽度">
        <el-input-number v-model="localSettings.width" :min="100" :max="2000"></el-input-number>
      </el-form-item>
      <el-form-item label="模板高度">
        <el-input-number v-model="localSettings.height" :min="100" :max="2000"></el-input-number>
      </el-form-item>
      <el-form-item label="纸张宽度">
        <el-input-number v-model="localSettings.paperWidth" :min="50" :max="500"></el-input-number>
        <span style="margin-left: 10px;">mm</span>
      </el-form-item>
      <el-form-item label="纸张高度">
        <el-input-number v-model="localSettings.paperHeight" :min="50" :max="500"></el-input-number>
        <span style="margin-left: 10px;">mm</span>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      localSettings: { ...this.value }
    };
  },
  watch: {
    localSettings: {
      deep: true,
      handler(newVal) {
        this.$emit('input', newVal);
        this.$emit('change', newVal);
      }
    },
    value: {
      immediate: true,
      handler(newVal) {
        this.localSettings = { ...newVal };
      }
    }
  }
};
</script>